var getWeixincofig = require("./getconfig.js");
getWeixincofig(shareweixin);


function shareweixin(data) {

  var data = JSON.parse(data);
  console.log(data);

  window.wx.config({
    debug:true,
    appId: data.appId,
    timestamp: data.timestamp,
    nonceStr: data.nonceStr,
    signature: data.signature,
    jsApiList: ['checkJsApi', 'onMenuShareTimeline', 'onMenuShareAppMessage']
  });

  wxShare();
}

function wxShare() {
  //检测api是否生效
  wx.ready(function() {
    wx.checkJsApi({
      jsApiList: [
        'getNetworkType',
        'previewImage'
      ],
      success: function(res) {
        console.log(JSON.stringify(res));
      }
    });
    //分享给好友
    wx.onMenuShareAppMessage({
      title: '趣学车-有温度的互联网驾校',
      desc: '想去学车，就趣学车!',
      link: 'http://www.goxueche.com',
      imgUrl: 'http://www.goxueche.com/....png'
    });
    
    //分享到朋友圈
    wx.onMenuShareTimeline({
      title: '趣学车-有温度的互联网驾校',
      desc: '想去学车，就趣学车!',
      link: 'http://www.goxueche.com',
      imgUrl: 'http://www.goxueche.com/....png'
    });

  });
}